package character.race;

import utilities.MinMaxPair;

/**
 * Partner configuraiton class.
 * @author pcdejager
 *
 */
public class RacePartner {
    /**
     * Partner configuration.
     * @param partnerStart Partner start age
     * @param partnerC Partner minimum and maximum constant
     * @param partnerM Partner minimum and maximum multiplier
     */
    public RacePartner(
            final int partnerStart,
            final MinMaxPair<Integer> partnerC,
            final MinMaxPair<Double> partnerM) {
        partnerStartAge = partnerStart;
        partnerConstant = partnerC;
        partnerMultiplier = partnerM;
    }

    /**
     * Get the age where race can have partner.
     * @return The start age
     */
    public final int getPartnerStartAge() {
        return partnerStartAge;
    }

    /**
     * Given the age, return the minimum age of a partner.
     * @param age The age
     * @return The min age
     */
    public final int getPartnerMinimumAge(final int age) {
        if (age < partnerStartAge) {
            return -1;
        }
        return ((int) ((double) age * partnerMultiplier.getMinimum()))
                + partnerConstant.getMinimum();
    }

    /**
     * Given the age, return the maximum age of a partner.
     * @param age The age
     * @return The max age
     */
    public final int getPartnerMaximumAge(final int age) {
        if (age < partnerStartAge) {
            return -1;
        }
        return ((int) ((double) age * partnerMultiplier.getMaximum()))
                + partnerConstant.getMaximum();
    }

    /**
     * The age race can have partner.
     */
    private int partnerStartAge = 0;
    /**
     * The partner minimum and maximum multiplier.
     */
    private MinMaxPair<Double> partnerMultiplier = null;
    /**
     * The partner minimum and maximum constant.
     */
    private MinMaxPair<Integer> partnerConstant = null;
}
